package cn.weiyang.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import com.github.pagehelper.PageInfo;

import cn.weiyang.model.Student;
import cn.weiyang.service.StudentService;

@Controller
@RequestMapping("/student")
public class StudentController {
	@Autowired
	private StudentService studentService;
	
	/**
	 * ����ѧ����Ϣ
	 * @param student
	 */
	@ResponseBody
	@PostMapping("/add")
	public void add(/*@RequestParam(name = "student", required = true) */Student student) {
		studentService.insert(student);
	}
	
	/**
	 * ��ҳ��ѯ����ѧ����Ϣ
	 * @param pageNum
	 * @param pageSize
	 * @return
	 */
	@ResponseBody
	@PostMapping("/all")
	public PageInfo<Student> selectStudents(
			@RequestParam(name = "pageNum", required = false, defaultValue = "1") int pageNum, 
			@RequestParam(name = "pageSize", required = false, defaultValue = "10") int pageSize){
		return studentService.selectStudents(pageNum, pageSize);
	}

}
